//
//  CAOrderDetailShippingView.m
//  LNH
//
//  Created by twentylx on 2018/2/14.
//  Copyright © 2018年 twentylx. All rights reserved.
//

#import "CAOrderDetailShippingView.h"

@implementation CAOrderDetailShippingView

/**
 为视图绑定 viewModel
 
 @param viewModel 要绑定的ViewModel
 @param params 额外参数
 */
- (void)bindViewModel:(id <LMViewProtocol>)viewModel withParams:(NSDictionary *)params {
    
}

/**
 初始化额外数据
 */
- (void)lm_initializeForView {
    self.backgroundColor = [UIColor whiteColor];
}

/**
 初始化视图
 */
- (void)lm_createViewForView {
    [self setNeedsUpdateConstraints];
    
    [self addSubview:self.shippingTitleLabel];
    [self addSubview:self.shippingButton];
    [self addSubview:self.lineView];
    [self addSubview:self.companyLabel];
    [self addSubview:self.companyNoLabel];
}

#pragma mark layout
- (void)updateConstraints {
    [super updateConstraints];
    
    [self.shippingTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(20);
        make.top.equalTo(self).offset(20);
    }];
    
    [self.shippingButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self).offset(-20);
        make.top.equalTo(self).offset(20);
        make.width.mas_equalTo(100);
        make.height.mas_equalTo(30);
    }];
    
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.and.right.equalTo(self);
        make.top.equalTo(self.shippingButton.mas_bottom).offset(20);
        make.height.mas_equalTo(1);
    }];
    
    [self.companyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(20);
        make.top.equalTo(self.lineView.mas_bottom).offset(10);
    }];
    
    [self.companyNoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(20);
        make.top.equalTo(self.companyLabel.mas_bottom).offset(5);
    }];
}

#pragma mark get & set
- (UILabel *)shippingTitleLabel {
    if (!_shippingTitleLabel) {
        _shippingTitleLabel = [UILabel new];
        _shippingTitleLabel.text = @"物流信息";
        _shippingTitleLabel.font = [UIFont systemFontOfSize:16];
    }
    return _shippingTitleLabel;
}

- (UIButton *)shippingButton {
    if (!_shippingButton) {
        _shippingButton = [UIButton new];
        [_shippingButton setTitle:@"查看物流" forState:UIControlStateNormal];
        [_shippingButton setTitleColor:RGBCOLOR(62, 62, 62) forState:UIControlStateNormal];
        _shippingButton.titleLabel.font = [UIFont systemFontOfSize:16];
        _shippingButton.layer.borderWidth = 1;
        _shippingButton.layer.borderColor = [RGBCOLOR(157, 157, 157) CGColor];
        _shippingButton.layer.cornerRadius = 5;
    }
    return _shippingButton;
}

- (UIView *)lineView {
    if (!_lineView) {
        _lineView = [UIView new];
        _lineView.backgroundColor = RGBCOLOR(241, 241, 241);
    }
    return _lineView;
}

- (UILabel *)companyLabel {
    if (!_companyLabel) {
        _companyLabel = [UILabel new];
        _companyLabel.text = @"物流公司：中通快递";
        _companyLabel.textColor = RGBCOLOR(62, 62, 62);
        _companyLabel.font = [UIFont systemFontOfSize:16];
    }
    return _companyLabel;
}

- (UILabel *)companyNoLabel {
    if (!_companyNoLabel) {
        _companyNoLabel = [UILabel new];
        _companyNoLabel.text = @"物流单号：239234923949";
        _companyNoLabel.textColor = RGBCOLOR(62, 62, 62);
        _companyNoLabel.font = [UIFont systemFontOfSize:16];
    }
    return _companyNoLabel;
}
@end

